<?php
namespace pinduoduo\Request;

use pinduoduo\AbstractInterface\Request;

class PddGoodsCatsGetRequest extends Request
{

    /**
     * 商品标准类目接口
     * @var string
     */
    private $type = 'pdd.goods.cats.get';

    /**
     * 值=0时为顶点cat_id,通过树顶级节点获取cat树
     * @var
     */
    private $parentCatId;

    public function setType($type)
    {
        $this->type = $type;
    }

    public function getType()
    {
        return $this->type;
    }

    public function setParentCatId($parentCatId)
    {
        $this->parentCatId = $parentCatId;
    }

    public function getParentCatId()
    {
        return $this->parentCatId;
    }

    public function getParams()
    {
        $params = [
            'type'          => $this->type,
            'parent_cat_id' => $this->parentCatId,
        ];
        $buildParams = [];
        foreach ($params as $key => $value) if ($value === 0) $buildParams[$key] = $value;
        return array_merge(array_filter($params), $buildParams);
    }
}
